<%@page isELIgnored="false" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>

<div>
 <tiles:insertDefinition name="admin.menus.courses"/>
 <table cellspacing="0" cellpadding="0" class="table_list">
  <tbody>
  
  <tr>
    <td class="tab_header">ID</td>
    <td class="tab_header">Title</td>
    <td class="tab_header">Last Modified</td>
    <td class="tab_header">Course Program</td>    
    <td class="tab_header">Actions</td>
  </tr>
    
	<c:forEach items="${courses}" var="course">
	<c:set var="highlightStyle" value=""/>
	<c:if test="${highlightID == course.id}">
		<c:set var="highlightStyle" value="background-color: HoneyDew"/>
	</c:if>	
  	<tr style="${highlightStyle}">
  		<td><a href="/admin/courses/view.do?id=${course.id}">${course.code}</a></td>
    	<td>${course.title}</td>
    	<td>${course.modified}</td>
    	<td><a href="/serve.do?key=${course.fileKey}"><spring:message code="view.program"/></a></td>
    	<td>
			<a href="/admin/courses/hatch.do?id=${course.id}&redirectURL=/admin/courses/available.do&highlightID=${course.id}" title="Hatch course (make it available)"><img src="/img/approve.png" width="16" height="16" border="0"/></a>
			<a href="/admin/courses/edit.do?id=${course.id}&redirectURL=/admin/courses/hatching.do&highlightID=${course.id}" title="Edit this course"><img src="/img/edit.jpg" width="16" height="16" id="editIcon" border="0"/></a>			    			
		</td>    			
   	</tr>
   	
   	</c:forEach>
	   	
</tbody></table>
</div>

<div class="admin_paging">
      <ul>
      <c:forEach begin="1" end="${pages}" step="1" var="num">
      	<c:choose>
      		<c:when test="${num == page}">
      			<li><a class="current" href="/admin/courses/hatching.do?page=${num}">${num}</a></li>
      		</c:when>
      		<c:otherwise>
      			<li><a href="/admin/courses/hatching.do?page=${num}">${num}</a></li>
      		</c:otherwise>
      	</c:choose>
      </c:forEach>
      <c:choose>
      	<c:when test="${page lt pages}">
        	<li><a class="next" href="/admin/courses/hatching.do?page=${page + 1}">NEXT</a></li>
      	</c:when>
      	<c:otherwise>
      	</c:otherwise>
      </c:choose>
      </ul>
</div>